package models

import (
	mysql2 "gitee.com/xuxinzhi2206/corehub/database/mysql"
	"gorm.io/gorm"
)

type UserShop struct {
	gorm.Model
	Username string `gorm:"type:varchar(20);not null"`
	Password string `gorm:"type:varchar(20);not null"`
	Phone    string `gorm:"type:varchar(11);not null"`
	Address  string `gorm:"type:varchar(100);not null"`
	Email    string `gorm:"type:varchar(20);not null"`
}

func (u *UserShop) LoginOne(username string) (info *UserShop, err error) {
	return u, mysql2.WithMysql(func(db *gorm.DB) error {
		return db.Table("user_shops").Where("username = ?", username).First(&info).Error
	})
}

func (u *UserShop) LoginTow(phone string) (info *UserShop, err error) {
	return u, mysql2.WithMysql(func(db *gorm.DB) error {
		return db.Table("user_shops").Where("phone = ?", phone).First(&info).Error
	})
}
